package com.cs.bd.dyload.update;

import android.content.Context;
import android.text.TextUtils;

public abstract class AbsClientParams {
    private static final long AN_HOUR = 3600000L;
    private static final long ONE_DAY_MILLS = 86400000L;
    protected AbsClientParams.IBuyChannelChanged mListener;
    protected String mBuyChannel;
    protected String mUserFrom;

    public AbsClientParams() {
    }

    public abstract String getCid();

    public abstract String getEntranceId();

    public String getBuyChannel() {
        return this.mBuyChannel;
    }

    public void setBuyChannel(String buyChannel) {
        if (!TextUtils.equals(this.mBuyChannel, buyChannel)) {
            this.mBuyChannel = buyChannel;
            if (this.mListener != null) {
                this.mListener.onBuyChannelChanged(this);
            }
        }

    }

    public String getUserFrom() {
        return this.mUserFrom;
    }

    public void setUserFrom(String buyChannel, String useFrom) {
        if (!TextUtils.equals(this.mBuyChannel, buyChannel) || !TextUtils.equals(this.mUserFrom, useFrom)) {
            this.mBuyChannel = buyChannel;
            this.mUserFrom = useFrom;
            if (this.mListener != null) {
                this.mListener.onBuyChannelChanged(this);
            }
        }

    }

    public abstract long getInstalledTime();

    public abstract boolean getIsUpgrade();

    public void addBuyChannelListener(AbsClientParams.IBuyChannelChanged listener) {
        this.mListener = listener;
    }

    public void removeBuyChannelListener(AbsClientParams.IBuyChannelChanged listener) {
        if (this.mListener == listener) {
            this.mListener = null;
        }

    }

    public final int getCDays(Context context) {
        return 1;
//        return AdSdkApi.calculateCDays(context, this.getInstalledTime());
    }

    public String toString() {
        return String.format("AbsClientParams--> cid:%s, entranceId:%s, buyChannel:%s, userFrom:%s, installedTime:%d, isUpgrade:%b", this.getCid(), this.getEntranceId(), this.getBuyChannel(), this.getUserFrom(), this.getInstalledTime(), this.getIsUpgrade());
    }

    public boolean isBuyChannelEqual(AbsClientParams params) {
        return params != null && TextUtils.equals(this.mBuyChannel, params.mBuyChannel) && TextUtils.equals(this.mUserFrom, params.mUserFrom);
    }

    public interface IBuyChannelChanged {
        void onBuyChannelChanged(AbsClientParams var1);
    }
}
